<template>
	<view>
		<NewsDetView
			v-if="newsData"
			:title="newsData.title"
			:author="newsData.author"
			:time="newsData.time"
			:comments="newsData.comments"
			:contentBlocks="newsData.contentBlocks"
		></NewsDetView>
	</view>
</template>

<script>
import NewsDetView from '../../../../components/NewsDetView.vue';

export default {
	components: { NewsDetView },
	data() {
		return {
			newsData: null
		};
	},
	onLoad(options) {
		const app = getApp();
		const index = parseInt(options.index);
		if (app.globalData && app.globalData.newsList && app.globalData.newsList[index]) {
			this.newsData = app.globalData.newsList[index];
		} else {
			console.error('未找到对应新闻数据');
			uni.navigateBack();
		}
	}
};
</script>

<style></style>